package bigraph.model;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.gef.requests.CreationFactory;

public class NodeCreationFactory implements CreationFactory {

	private Class<?> template;
	
	public NodeCreationFactory(Class<?> t) {
	     this.template = t;
	}
	
	@Override
	public Object getNewObject() {
		if (template == null)
		      return null;
		if (template == Root.class)
		{
		       Root rt = new Root();
		       rt.setName("Root: no.");
		       return rt;
		  }
		if (template == Site.class)
		{
		       Site st = new Site();
		       st.setName("Site: no.");
		       st.setColor(ColorConstants.red);
		       return st;
		  }
		if (template == Place.class)
		{
		       Place plc = new Place();
		       plc.setColor(ColorConstants.white);
		       plc.setName("Place");
		       return plc;
		}
		  return null;
	}


	@Override
	public Object getObjectType() {
		return template;
	}

}
